{include file="public/header" /}
<span class="layui-breadcrumb">
  <a href="javascript:;">新闻事件</a>
  <a><cite>列表</cite></a>
</span>
<div class="layui-fluid">
    <div class="layui-card">
      <div class="layui-card-body">
        <div style="color:#FF5722">新闻事件分类</div>
        <div class="layui-form">
          <a class="layui-btn layui-btn-normal layui-btn-sm" target="_blank" href="{:url('Eventsclass/change')}?nav=events-eventsclasslist">添加</a>
      
          <div class="layui-form-item" style='margin-top:20px'>
            <!-- <div class="layui-inline">
              <label class="layui-form-label">标题</label>
              <div class="layui-input-inline">
                <input type="text" class="layui-input" name='title' placeholder="请输入标题">
              </div>
            </div> -->
            <!-- <div class="layui-inline">
              <button type="button" class="layui-btn layui-btn-primary layui-btn-sm" onclick="sear()">查询</button>
              <a href="{:url('Events/index')}?nav=events-eventslist" class="layui-btn layui-btn-sm layui-btn-danger">清空</a>
            </div> -->
          </div>
      
          <table class="layui-hide" id="test" lay-filter="test"></table>

        </div>

      </div>  
    </div>
</div>

{include file="/public/footer" /}
<script>
layui.use('table', function(){
  var table = layui.table;
  table.render({
    elem: '#test'
    ,url:'/admin/Eventsclass/get_data/'
    ,title: '新闻事件分类'
    ,cols: [[
      {field:'title', title:'名称'}
      ,{field:'title_en', title:'英文名称'}
      ,{field:'seq', title:'排序'}
      ,{fixed: 'right', title:'操作', templet: function(res){
        var str='<button type="button" class="layui-btn layui-btn-danger layui-btn-xs" onclick="del('+res.class_id+')">删除</button>';
            str+='<a target="_blank" href={:url("Eventsclass/change")}?nav=events-eventsclasslist&id='+res.class_id+' class="layui-btn layui-btn-xs">编辑</a>';
        return str;  
      }}
    ]]
    ,page: true
  });
});



  function del(id){
    layer.confirm('你确定要删除吗', {
      btn: ['确定','取消'] //按钮
    }, function(){
      layer.load();
      $.post("{:url('Eventsclass/del')}",{id:id},function(res){
          if(res.status=='0'){
              layer.closeAll('loading');
              layer.msg(res.msg);
          }
          if(res.status=='1'){
              layer.msg(
              res.msg,{icon: 1,time: 600},
              function(){
                layer.closeAll('loading');
                location.href=location.href;
              });
          }
      })
    });
  }


  /*查询*/
  function sear(){
    
    var title=$.trim($("input[name='title']").val());
    if(title==''){
        layer.msg('请输入查询条件');
        return false;
    }
    window.location.href="{:url('Eventsclas/get_data')}"+"?nav=events-eventslist?title="+title;
  }


</script>
